<?php
/*
// @author : lael
// blog : http://hi.baidu.com/lael80
// http://www.gzyd.net
// all right reserved.
*/
namespace ydsdk\models;
class student extends \ydsdk\core\common {
	public function __construct(){
		parent::__construct();
	}

	public function get_by_phone($phone)
	{
		$sql = "SELECT s.`name`, s.parentsphone, s.iccode, c.classes FROM ##deerxi_student AS s INNER JOIN ##deerxi_classes AS c ON s.cid = c.id WHERE s.parentsphone = '".$phone."'";
		$res = $this->db->get_row($sql);
		return $res;
	}
	
    /**
	 * 通过卡号，得到学生信息,包含学生所在班级，学校名称
	 *
	 * @access  public
	 * @return  row_array,
	 */
	public function get_full_by_iccode($iccode)
	{
		//$iccode = intval($iccode);
		$sql = "SELECT stu.id,stu.sid,stu.cid,stu.parid, stu.`name`, stu.sex, stu.sms_phone,stu.is_sms,stu.`code`, c.classes, a.`name` AS school, stu.headerimg FROM ##deerxi_student AS stu INNER JOIN ##deerxi_classes AS c ON stu.cid = c.id INNER JOIN ##admin AS a ON c.sid = a.admin_id INNER JOIN ##stu_iccode AS `code` ON stu.id = `code`.stu_id WHERE `code`.iccode = '".$iccode."'";
		$res = $this->db->get_row($sql);
		return $res;
	}	
	public function getTimeWeek($time, $i = -1) {
	  $weekarray = array("一", "二", "三", "四", "五", "六", "日");
	  $oneD = 24 * 60 * 60;
	  return "周" . $weekarray[date("w", $time + $oneD * $i)];
	}
	
	
}